<template>
  <section class="page">
    <headerbar
    >支部空间
      <span
        v-if="/*maintainable !== '4'*/ AddSpaceFlag"
        class="head-btn"
        slot="btn"
        @click="goAddSpace()"
      >支部信息</span
      >
    </headerbar>

    <div class="banner">
      <div class="block-img">
        <!-- <img v-if="!partInfoData.cover || partInfoData.cover===''" src="../../../../static/images/dangjian/dangwu/branch_bg.png" alt="">
        <img :src="showImg(partInfoData.cover)" alt="">-->

        <bannerImg
          v-if="partInfoData.cover"
          :url="showImg(partInfoData.cover, true)"
        ></bannerImg>

        <div class="inner-text">
          <div class="group-name">{{ partInfoData.alias }}</div>
          <div class="banner-avatar-info" v-if="false">
            <div class="avatar-wrap" v-if="false">
              <div class="avatar">
                <img
                  v-if="!partInfoData.avatar || partInfoData.avatar === ''"
                  :src="showImg(partInfoData.avatar, true)"
                  alt=""
                />
                <img
                  v-if="partInfoData.avatar && partInfoData.avatar !== ''"
                  src="../../../../static/images/dangjian/dangwu/branch_avatar.png"
                  alt=""
                />
              </div>
            </div>
            <div class="info">
              <h1>{{ partInfoData.alias }}</h1>
              <p class="text">{{ partInfoData.signature }}</p>
            </div>
            <!--<div class="org-name">{{partInfoData.orgTypeName}}</div>-->
          </div>
        </div>
      </div>
    </div>

    <section class="">
      <div class="bg-white">
        <div class="pdv-1"></div>
        <ul class="line-tab mgt-0 noborder">
          <li @click="branchMembers()" :class="{ active: tabIndex == 1 }">
            <span
            >成员<i class="icon icon-msg"><i class="num"></i></i
            ></span>
          </li>
          <li @click="memorabilia()" :class="{ active: tabIndex == 2 }">
            <span
            >纪事<i v-if="zbdsjRead != 0" class="icon icon-msg"
            ><i class="num" v-if="false">{{ zbdsjRead }}</i></i
            ></span
            >
          </li>
          <li @click="honor()" :class="{ active: tabIndex == 3 }">
            <span
            >荣誉
              <!--              <i v-if="zbxcRead != 0" class="icon icon-msg"
                              ><i class="num">{{ zbxcRead }}</i></i
                            >-->
            </span
            >
          </li>
          <li @click="album()" :class="{ active: tabIndex == 6 }">
            <span
            >相册<i v-if="zbxcRead != 0" class="icon icon-msg"
            ><i class="num">{{ zbxcRead }}</i></i
            ></span
            >
          </li>
          <li @click="learningMaterials()" :class="{ active: tabIndex == 5 }">
            <span
            >资料<i v-if="xxzljRead != 0" class="icon icon-msg"
            ><i class="num">{{ xxzljRead }}</i></i
            ></span
            >
          </li>
          <li @click="learningExperience()" :class="{ active: tabIndex == 4 }">
            <span
            >交流</span
            >
          </li>
        </ul>
      </div>

      <!--支部成员-->
      <section class="d-scroll bg-white mgt-2 pdh-2" v-if="tabIndex === 1">
        <abnormal
          class="people-list"
          @refresh="branchMembers"
          v-if="abnormal"
        ></abnormal>
        <fetchData
          class="people-list"
          :loading="isLoading"
          :data="list"
        ></fetchData>
        <section class="people-list">
          <div class="block people-item" v-for="(item, index) in list" :key="index">
            <div class="user-avatar">
              <div class="avatar-img">
                <img
                  v-if="item.imageUrl && item.imageUrl !== ''"
                  :src="showImg(item.imageUrl, true)"
                  alt=""
                />
                <img
                  v-if="!item.imageUrl || item.imageUrl === ''"
                  src="../../../../static/images/default.jpg"
                  alt=""
                />
              </div>
              <span class="pdh-2"></span>
              <div>
                <p class="name">{{ item.userName }}（{{ item.partyId }}）</p>
                <p class="color-tip">{{ item.position }}</p>
              </div>
            </div>
            <span class="" @click="callNumber(item.mobile)"
            ><span class="tip pdh-2">{{ item.mobile }}</span
            ><span class="color-tip fa fa-phone-alt"></span
            ></span>
          </div>
        </section>
        <div
          class="text-center no-data"
          :loading="isLoading"
          :data="list"
          v-if="!abnormal && !isLoading && list.length === 0"
        >
          <img src="../../../../static/images/no_data.png" alt=""/>
          <p>暂无数据</p>
        </div>
        <p class="pdv-10"></p>
        <p class="pdv-10"></p>
        <p class="pdv-10"></p>
      </section>
      <!--支部大事记-->
      <section class="d-scroll bg-white mgt-2 pdh-2" v-if="tabIndex === 2">
        <!--<section class="people-list ">
          <div class="pdv-2"></div>
          <div class="people-item" v-for="item in memorabilias" @click="goMemorabiliasDetail(item, 2)">
            <div class="avatar-img" v-if="false">
              <img v-if="item.userImage && item.userImage !== ''" :src="showImg(item.userImage)" alt="">
              <img v-if="!item.userImage || item.userImage === ''" src="../../../../static/images/user_bg.jpg" alt="">
            </div>
            <div class="cont">
              <span class="name title">{{item.ext}}</span>
            </div>
            <span class="tip pdh-2"></span>
          </div>
        </section>-->

        <!--  <div class="block live-msg-wrap"  v-for="(item,index) in memorabilias" :key="index">
            <div class="user-avatar" v-if="false">
              <div class="avatar">
                <img v-if="item.userImage && item.userImage !== ''" :src="showImg(item.userImage)" alt="">
                <img v-if="!item.userImage || item.userImage === ''" src="../../../../static/images/user_bg.jpg" alt="">
              </div>
              <div class="info line-wrap-2 break-word">
                <h1><span class="bold">{{item.userName || item.fileName}}</span>    <span class="">更新</span> <span class="bold">{{item.ext}}</span></h1>
              </div>
            </div>
            <div class="info pdt-3">
              <h1><span class="">{{item.ext}}</span></h1>
            </div>
            <div class="live-msg" style="max-height:none;">

            </div>

            <div class="card-foot">
              <p class="text"><span class="icon-time"></span>{{getTime(item.createTime)}}</p>
              <div class="right">
                <upsLearn :key="'2'+index" :contentId="item.id" :commentId="item.id" :upsCount="item.countSupport"></upsLearn>
              </div>
            </div>
          </div>-->
        <fetchData
          class="live-msg-btn-wrap"
          :loading="isLoading"
          :data="memorabilias"
        ></fetchData>
        <abnormal
          class="people-list"
          @refresh="memorabilia"
          v-if="abnormal"
        ></abnormal>
        <cube-scroll ref="scroll" :options="optionsMemorabilia"  @pulling-up="onPullingUpMemorabilia" @pulling-down="onPullingDownMemorabilia">
          <cube-swipe :key="newmemorabilias">
            <transition-group name="swipe" tag="div">
              <div
                @dragstart="dragstart"
                draggable="true"
                class="live-msg-btn-wrap"
                v-for="(item, index) in memorabilias"
                :key="item.id"
              >
                <cube-swipe-item
                  :class="maintainable === '2'? '':'swiper-no-swiping'"
                  ref="swipeItem"
                  :btns="item.btns"
                  :index="index"
                  @btn-click="action"
                >
                  <div class="block pdv-3 pdh-3 live-msg-wrap">
                    <div class="info pdt-3">
                      <h1>
                        <span class="">{{ item.ext }}</span>
                      </h1>
                    </div>

                    <div v-if="false" class="card-foot">
                      <p class="text">
                        <span class="icon-time"></span
                        >{{ getTime(item.createTime) }}
                      </p>
                      <div class="right">
                        <upsLearn
                          :key="'2' + index"
                          :contentId="item.id"
                          :commentId="item.id"
                          :upsCount="item.countSupport"
                        ></upsLearn>
                      </div>
                    </div>
                  </div>
                </cube-swipe-item>
              </div>
            </transition-group>
          </cube-swipe>
          <noData
            v-if="!abnormal && !isLoading && memorabilias.length === 0"
          ></noData>
          <onBottom v-else-if="onBottom"></onBottom>
          <p class="pdv-10"></p>
          <!-- <div class="text-center no-data" :loading="isLoading" :data="memorabilias" v-if="!abnormal && !isLoading && memorabilias.length===0">
          <img src="../../../../static/images/no_data.png" alt="">
          <p>暂无数据</p>
        </div> -->
          <!-- W noData -->
        </cube-scroll>
        <section class="foot-action">
<!--          <div
            class="default-block-btn mgh-10"
            @click="goAdd('memorabiliasAdd')"
            v-if="maintainable === '2'"
          >-->
            <div
            class="default-block-btn mgh-10"
            @click="goAdd('memorabiliasAdd')"
            v-if="flagMaintainable"
          >
            添加支部纪事
          </div>

          <!--<div class="default-block-btn mgh-10" @click="goAdd('memorabiliasAdd')" >添加支部大事记</div>-->
        </section>
      </section>
      <!--支部相册-->
            <section class="bg-white mgt-2 pdh-2" v-if="tabIndex === 6">
              <fetchData :loading="isLoading" :data="albums"></fetchData>
              <abnormal
                class="people-list"
                @refresh="album"
                v-if="abnormal"
              ></abnormal>
              <div
                class="block live-msg-wrap pdv-4 border-my"
                @click="goAlbums(item, index)"
                v-for="(item, index) in albums"
                :key="index"
              >
                <div class="user-avatar" v-if="false">
                  <div class="avatar">
                    <img
                      v-if="tools.indexOfHttp(item.fileUrl)"
                      :src="item.fileUrl"
                      alt=""
                    />
                    <img
                      v-else-if="item.userImage && item.userImage !== ''"
                      :src="showImg(item.userImage, true)"
                      alt=""
                    />
                    <img
                      v-if="!item.userImage || item.userImage === ''"
                      src="../../../../static/images/user_bg.jpg"
                      alt=""
                    />
                  </div>
                  <div class="info">
                    <h1>
                      <span class="bold">{{ item.userName || item.fileName }}</span>
                      <span class="">更新</span>
                      <span class="bold">{{ item.title }}</span>
                    </h1>
                  </div>
                </div>
                <div class="info" v-if="false">
                  <h1>
                    <span class="bold">{{ item.title }}</span>
                  </h1>
                </div>
                <div class="live-msg" style="max-height: none">
                  <section class="list-news-img list-albums">
                    <div class="item" style="padding: 0">
                      <div class="img">
<!--                        <img
                          v-if="tools.indexOfHttp(item.fileUrl)"
                          :src="item.fileUrl"
                          alt=""
                        />
                        <img
                          v-else-if="item.fileId && item.fileId !== ''"
                          :src="showImg(item.fileId, true)"
                          alt=""
                        />-->
                        <div class="imgs" v-saveImage>
                          <div v-if="tools.indexOfHttp(item.fileUrl)" class="img"
                               :style="{'background-image':'url(' + item.fileUrl + ')'}">
                          </div>
                          <div v-else-if="item.fileId && item.fileId !== ''" class="img"
                               :style="{'background-image':'url(' + showImg(item.fileId, true) + ')'}">
                          </div>
                        </div>
                      </div>
                      <div class="cont">
                        <h2
                          class="title albums-text"
                          v-html="tools.resumeEnter(item.title)"
                        ></h2>
                        <div class="tip"></div>
                      </div>
                      <div v-if="item.readResult == 0" class="color-red">未读</div>
                    </div>
                  </section>
                </div>

                <div class="card-foot" v-if="false">
                  <p class="text">
                    <span class="icon-time"></span>{{ getTime(item.createTime) }}
                  </p>
                  <div class="right">
                    <upsLearn
                      :key="'3' + index"
                      :contentId="item.id"
                      :commentId="item.id"
                      :upsCount="item.countSupport"
                    ></upsLearn>
                  </div>
                </div>
              </div>

              <p class="pdv-10"></p>
              <p class="pdv-10"></p>
              <p class="pdv-10"></p>
              <div
                class="text-center no-data"
                :loading="isLoading"
                :data="memorabilias"
                v-if="!abnormal && !isLoading && albums.length === 0"
              >
                <img src="../../../../static/images/no_data.png" alt="" />
                <p>暂无数据</p>
              </div>

              <!--<section class="d-scroll-2head list-news-img list-albums bg-white">
                <div class="item" @click="goAlbums(item, index)" v-for="(item,index) in albums" :key="index">
                  <div class="img">
                    <img v-if="item.userImage && item.userImage !== ''" :src="showImg(item.userImage)" alt="">
                    <img v-if="!item.userImage || item.userImage === ''" src="../../../../static/images/user_bg.jpg" alt="">
                  </div>
                  <div class="cont">
                    <h2 class="title">{{item.title}}</h2>
                    <div class="tip">
                      <span>{{getTime(item.createTime)}}</span>
                  </div>
                  </div>
                </div>
                <p class="pdv-10"></p>
                <p class="pdv-10"></p>
                <p class="pdv-10"></p>
                <div class="text-center no-data" v-if="albums.length===0">
                  <img src="../../../../static/images/no_data.png" alt="">
                  <p>暂无数据</p>
                </div>
              </section>-->

              <section class="foot-action">
                <div class="default-block-btn mgh-10" @click="goAdd('albumsAdd')" v-if="flagMaintainable">
                  添加支部相册
                </div>
              </section>
            </section>

      <!--      荣誉-->
      <section class="bg-white mgt-2 pdh-2" v-if="tabIndex === 3">
        <honorComponent></honorComponent>
        <section class="foot-action">
          <div
            class="default-block-btn mgh-10"
            @click="goAdd('honorAdd')"
            v-if="/*maintainable === '1' || maintainable === '2'*/ flagMaintainable"
          >
            添加支部荣誉
          </div>
        </section>
      </section>
      <!--学习体会-->
      <section class="mgt-2 pdh-2 page-my" v-if="tabIndex === 4">
        <cube-scroll ref="scroll" :options="optionsTopic"  @pulling-up="onPullingUpTopic" @pulling-down="onPullingDownTopic">
        <fetchData
          class="live-msg-wrap pdv-4"
          :loading="isLoading"
          :data="learningExperiences"
        ></fetchData>
        <abnormal
          class="people-list"
          @refresh="learningExperience"
          v-if="abnormal"
        ></abnormal>
        <div
          class="block live-msg-wrap study-my"
          @click="goTopicDetail(item,index)"
          v-for="(item, index) in learningExperiences"
          :key="index"
        >
          <div class="user-avatar">
            <div class="avatar">
              <img
                v-if="item.createUser"
                :src="tools.getAvatarUrl(item.createUser)+'&'+Date.now()"
                alt=""
              />
              <img
                v-else=""
                src="../../../../static/images/user_bg.jpg"
                alt=""
              />
            </div>
            <div class="info">
              <div class="head-my">
                <div>{{ item.createUserName }}</div>
                <div v-if="isMySelf(item)" @click.stop="del(item.id,index,'topic')" class="right">删除
                </div>
              </div>
              <li class="header-my">{{ getTimeNew(item.createTime) }} · 添加了话题</li>
            </div>
          </div>
          <div class="live-msg" v-html="tools.resumeEnter(item.title)" ></div>
          <div class="card-foot-my">
            <span class="span-my" v-html="tools.resumeEnter(item.content)">
            </span>
            <p class="text">
              {{ item.participantsTotal }}&nbsp;人参与了话题
            </p>
          </div>
        </div>

        <section class="people-list">
          <!--<div class="people-item" v-for="item in learningExperiences" @click="goMemorabiliasDetail(item, 4)">
            <div class="avatar-img" v-if="false">
              <img v-if="item.userImage && item.userImage !== ''" :src="showImg(item.userImage)" alt="">
              <img v-if="!item.userImage || item.userImage === ''" src="../../../../static/images/user_bg.jpg" alt="">
            </div>
            <div class="cont">
              <span class="name">{{item.title}}</span>
              <div class="color-tip">{{getTime(item.createTime)}}</div>
            </div>
            <span class="tip pdh-2"></span>
          </div>-->
          <div
            class="text-center no-data"
            :loading="isLoading"
            :data="learningExperiences"
            v-if="!abnormal && !isLoading && learningExperiences.length === 0"
          >
            <img src="../../../../static/images/no_data.png" alt=""/>
            <p>暂无数据</p>
          </div>
          <onBottom v-else-if="onBottom"></onBottom>
          <p class="pdv-10"></p>
        </section>
        </cube-scroll>
        <section class="foot-action">
          <div
            class="default-block-btn mgh-10"
            @click="goAdd('learningExperiencesAdd')"
            v-if="/*maintainable !== '4'*/ flagMaintainable"
          >
            发起话题
          </div>
        </section>
      </section>
      <!--学习资料-->
      <section class="bg-white mgt-2 pdh-2 page-my" v-if="tabIndex === 5">
        <cube-scroll ref="scroll" :options="options" @pulling-up="onPullingUp" @pulling-down="onPullingDown">
          <abnormal
            class="people-list"
            @refresh="learningMaterials"
            v-if="abnormal"
          ></abnormal>
          <fetchData :loading="isLoading" :data="learningMaterialses"></fetchData>
          <ul class="people-list">
            <li
              class="block people-item people-item-my"
              v-for="(data, index) in learningMaterialses"
              :key="data.id"
              @click="goMemorabiliasDetail(data, 5)"
            >
              <!--<div class="inner">
                <div class="bd">
                  <div class="title">{{data.title}}</div>
                </div>
                <div class="ft" v-if="false">
                  <div class="btn-line" @click="download(data)">下载</div>
                </div>
              </div>-->
              <div class="avatar-img">
                <img
                  v-if="data.userImage && data.userImage !== ''"
                  :src="showImg(data.userImage, true)"
                  alt=""
                />
                <img
                  v-if="!data.userImage || data.userImage === ''"
                  src="../../../../static/images/default.jpg"
                  alt=""
                />
              </div>
              <div class="cont">
                <span class="name">{{ data.title }}</span>
                <div class="color-tip">{{ getTime(data.createTime) }}</div>
              </div>
              <div class="right-my">
                <div v-if="isMySelf(data)" @click.stop="del(data.id,index,'Materialses')" class="color-red">删除</div>
                <div v-if="data.readResult == 0 && !isMySelf(data)" class="color-red">未读</div>
              </div>
            </li>
          </ul>
          <noData
            v-if="!abnormal && !isLoading && learningMaterialses.length === 0"
          ></noData>
          <onBottom v-else-if="onBottom"></onBottom>
          <p class="pdv-10"></p>
          <p class="pdv-3"></p>
        </cube-scroll>
          <section class="foot-action">
            <div
              class="default-block-btn mgh-10"
              @click="goAdd('learningMaterialsesAdd')"
              v-if="flagMaintainable"
            >
              添加学习资料
            </div>
          </section>
      </section>
    </section>
  </section>
</template>

<script>
import moment from "moment";
import tools from "@/utils/tools";
import api from "@/common/config/api";
import upsLearn from "@/components/common/upsLearnComponent.vue";
import honorComponent from "@/components/common/honorComponent.vue";
import loginService from '@/service/loginService'

let userInfo = {};
export default {
  name: "branchSpace",
  components: {upsLearn, honorComponent},
  data() {
    return {
      fn: tools,
      data: {},
      tabIndex: 1,
      list: [],
      memorabilias: [],
      albums: [],
      learningExperiences: [],
      learningMaterialses: [],
      spaceCovers: [],
      isLoading: true,
      abnormal: false,
      id: "",
      newmemorabilias: "",
      partInfoData: {},
      spaceCoverFileId: "",
      noReadList: [],
      zbdsjRead: 0,
      zbxcRead: 0,
      xxthjRead: 0,
      xxzljRead: 0,
      maintainable: "",
      onBottom: false, // W onBottom
      userInfo: '',
      options: {
        pullUpLoad: true,
        scrollbar: false,
        pullDownRefresh: {
          threshold: 90,
          stop: 0,
          txt: ' '
        },
      },
      optionsMemorabilia: {//支部纪事的上拉下拉刷新
        pullUpLoad: true,
        scrollbar: false,
        pullDownRefresh: {
          threshold: 90,
          stop: 0,
          txt: ' '
        },
      },
      memorabiliaIndex:1,//支部纪事的页码
      optionsTopic: {//学习交流的上拉下拉刷新
        pullUpLoad: true,
        scrollbar: false,
        pullDownRefresh: {
          threshold: 90,
          stop: 0,
          txt: ' '
        },
      },
      learningExperiencesIndex:1,
      pageIndexLearning:1,
      flagMaintainable:false,//列表的新增权限
      AddSpaceFlag:false,//支部信息修改权限
    };
  },
  created() {
    this.tabIndex = this.$store.state.branchIndex || 1;
    this.maintainable = this.$store.state.maintainable;
    console.log('this.maintainable',this.maintainable);
    this.userInfo = this.$localStorage.get("userInfo");
    this.id = this.$route.params.id;
    let methods = {
      1: "branchMembers",
      2: "memorabilia",
      // 3: "album",
      3: "honor",
      4: "learningExperience",
      5: "learningMaterials",
      6: "album",
    };
    this[methods[this.tabIndex]]();
    //      this.branchMembers()
    this.partInfo();
    this.getByTypeAddSpace('zbxx')//支部信息请求
    // this.spaceCover()
    this.readSpaceInfoStatusList();
  },
  /*beforeRouteLeave(to, from, next) {
    this.$route.meta.keepAlive = to.name === 'branchTopicDetail'
    if (this.$route.meta.keepAlive) {
      this.$store.commit('addRoute','branchSpace')
    } else {
      this.$store.commit('removeRoute','branchSpace')
      this.$destroy()
    }
    next()
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      to.meta.keepAlive = true;
      vm.$store.commit("addRoute", "branchSpace");
    });
  },*/
  watch: {
    tabIndex(val, oldVal) {
      this.$store.state.branchIndex = val;
      /*1: "branchMembers",
        2: "memorabilia",
        // 3: "album",
        3: "honor",
        4: "learningExperience",
        5: "learningMaterials",
        6: "album",*/

     if(val == 2){//key(zbxx:支部信息、zbjs:纪事、zbry:荣誉、zbxc:相册、zbzl:资料、zbjl:交流)
       this.getByType('zbjs')//zbjs:纪事
      }else if(val == 3){
       this.getByType('zbry')//zbry:荣誉
      }else if(val == 4){
       this.getByType('zbjs')
      }else if(val == 5){
       this.getByType('zbzl')//zbzl:资料
      }else if(val == 6){
       this.getByType('zbxc')//zbxc:相册
      }
      this.onBottom = false // 把已加载全部重置
    },
  },
  methods: {
    getByType(type) {
      // console.log('aaaaaa',this.getByTypeNew(type));
      let data = {
        typeKey: type
      }
      loginService.topic_getByType(data).then((res) => {
        if (res.code !== 0) {
          return tools.tip(res.message)
        }
        if (res.code === 0) {
          console.log('res.data=',res.data);
         this.flagMaintainable = res.data.addPower
        }
      })
    },
    getByTypeAddSpace(type) {
      let data = {
        typeKey: type
      }
      loginService.topic_getByType(data).then((res) => {
        if (res.code !== 0) {
          return tools.tip(res.message)
        }
        if (res.code === 0) {
          this.AddSpaceFlag = res.data.addPower
        }
      })
    },
    isMySelf(item) {//是否为自己
      if (item.createUser == this.userInfo.id) {
        return true
      }
      return false
    },
    del(id, index,type) {
      let _this = this
      this.$createDialog({
        type: 'confirm',
        title: "温馨提示",
        content: '确认删除？',
        confirmBtn: {
          text: '确定',
          active: true,
          disabled: false,
          href: 'javascript:;'
        },
        cancelBtn: {
          text: '取消',
          active: false,
          disabled: false,
          href: 'javascript:;'
        },
        onConfirm: () => {
          if(type ==='Materialses'){
            _this.deleteMaterialses(id, index);
          }
          if(type === 'topic'){
            _this.deleteMaterial(id, index);
          }
        },
        onCancel: () => {
        }
      }).show()
    },
    deleteMaterial(id, index) {
      this.fetchService.topic_delTopic(id).then(res => {
        if (res.code !== 0) {
          return this.tools.tip(res.message)
        }
        this.tools.tip("删除成功")
        this.learningExperiences.splice(index, 1)
      })
    },
    deleteMaterialses(id, index) {
      let data = {
        spaceId:id,
        spaceType:'5',
      }
      this.fetchService.saveSpaceInfoDelSpaceInfo(data).then(res => {
        if (res.code !== 0) {
          return this.tools.tip(res.message)
        }
        this.tools.tip("删除成功")
        this.learningMaterialses.splice(index, 1)
      })
    },
    branchMembers() {
      this.list = [];
      this.abnormal = false;
      this.isLoading = true;
      this.tabIndex = 1;
      let data = {
        loginId: "3750",
      };
      this.fetchService.findDzbUserList(data).then((res) => {
        this.isLoading = false;
        console.log(res);
        if (res.code !== 0) {
          if (res.code == 444) {
            this.abnormal = true;
            return;
          } else {
            return this.tools.tip(res.message);
          }
        }
        this.list = res.data;
      });
    },
    memorabilia() {
      // this.memorabilias = [];
      this.abnormal = false;
      this.isLoading = true;
      this.tabIndex = 2;
      let data = {
        loginId: "112029",
        orgId: this.id,
        spaceType: "2",
        pageNo: this.memorabiliaIndex,
        pageSize: 20,
      };
      return this.fetchService.spaceInfoList(data).then((res) => {
        this.isLoading = false;
        console.log(res);
        if (res.code !== 0) {
          if (res.code == 444) {
            this.abnormal = true;
            return;
          } else {
            return this.tools.tip(res.message);
          }
        }
        res.data.forEach((v, i) => {
          v.btns = [];
          v.btns.push({
            action: "edit",
            text: "修改",
            color: "#fecf54",
          });
          v.btns.push({
            action: "deleteItem",
            text: "删除",
            color: "#ec5563",
          });
          v.btns.push({
            action: "up",
            text: "上移",
            color: "#a2d171",
          });
          v.btns.push({
            action: "down",
            text: "下移",
            color: "#2cd1aa",
          });
        });
        this.isLoading = false;
        if (res.code === 0 && res.data.length < 1) {
          this.onBottom = true
          this.optionsMemorabilia.pullUpLoad = false
          this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate();
          return;
        }
        this.memorabiliaIndex++;
        this.memorabilias = this.memorabilias.concat(res.data)
        setTimeout(() => {
          this.$refs.scroll.forceUpdate &&
          this.$refs.scroll.forceUpdate(true, false);
        }, 100);
        // return (this.memorabilias = res.data);
      });
    },
    dragstart(e, ...arg) {
      console.log(e, arg);
    },
    action(btn, index) {
      //        console.log('edit', btn, index)
      let item = this.memorabilias[index];
      this[btn.action](item, index);
    },
    edit(item) {
      console.log("edit", item);
      this.$store.state.branchDetail = item;
      this.$router.push({name: "memorabiliasAdd", query: {id: item.id}});
    },
    deleteItem(item, index) {
      let params = {
        loginId: this.tools.getUserInfo().id,
        spaceId: item.id,
      };
      this.tools.showLoading();
      this.fetchService.saveSpaceInfoDelSpaceInfo(params).then((res) => {
        this.tools.hideLoading();
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
        this.memorabilias.splice(index, 1);
        this.tools.tip("删除成功");
        this.newmemorabilias = Date.now();
      });
    },
    up(item, index) {
      let prev = this.memorabilias[index < 1 ? 0 : --index];
      let params = {
        loginId: this.tools.getUserInfo().id,
        spaceId: item.id,
        sortNum: ++prev.sort,
        sortFlag: "custom",
      };
      this.tools.showLoading();
      this.fetchService.updateSpaceSort(params).then((res) => {
        this.tools.hideLoading();
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
        this.memorabilia().then((res) => {
          this.newmemorabilias = Date.now();
        });
      });
    },
    down(item, index) {
      let length = this.memorabilias.length;
      index++;
      if (index >= length) {
        return;
      }
      let next = this.memorabilias[index];
      let params = {
        loginId: this.tools.getUserInfo().id,
        spaceId: item.id,
        sortNum: --next.sort,
        sortFlag: "custom",
      };
      this.tools.showLoading();
      this.fetchService.updateSpaceSort(params).then((res) => {
        this.tools.hideLoading();
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
        this.memorabilia().then((res) => {
          this.newmemorabilias = Date.now();
        });
      });
    },
    album() {//原来学习资料
      this.albums = [];
      this.abnormal = false;
      this.isLoading = true;
      this.tabIndex = 6;
      let data = {
        loginId: userInfo.id || "112029",
        orgId: this.id,
        spaceType: "3",
        pageNo: "1",
        pageSize: "200",
      };
      this.fetchService.spaceInfoList(data).then((res) => {
        this.isLoading = false;
        console.log(res);
        if (res.code !== 0) {
          if (res.code == 444) {
            this.abnormal = true;
            return;
          } else {
            return this.tools.tip(res.message);
          }
        }
        this.albums = res.data;
      });
    },
    honor() {
      this.swipeData = []
      this.pageIndex = 1
      this.tabIndex = 3;
      // this.honorData()
    },
    learningExperience() {
      this.abnormal = false;
      this.isLoading = true;
      this.tabIndex = 4;
      let data = {
        loginId: "112029",
        orgId: this.id,
        spaceType: "4",
        pageNo: this.learningExperiencesIndex,
        pageSize: "10",
      };
      // this.fetchService.spaceInfoList(data).then((res) => {
      this.fetchService.topic_selectListByUserOrg(data).then((res) => {//新支部空间交流
        this.isLoading = false
        if (res.code !== 0) {
          if (res.code == 444) {
            this.abnormal = true;
            return;
          } else {
            return this.tools.tip(res.message);
          }
        }
        if (res.code === 0 && res.data.length < 1) {
          this.onBottom = true
          this.optionsTopic.pullUpLoad = false
          this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate();
          return;
        }
        this.learningExperiencesIndex++;
        this.learningExperiences = this.learningExperiences.concat(res.data)
        console.log('this.learningExperiences',this.learningExperiences);
        setTimeout(() => {
          this.$refs.scroll.forceUpdate &&
          this.$refs.scroll.forceUpdate(true, false);
        }, 100);
      });
    },
    onPullingUp() {
      console.log("onPullingUp");
      this.learningMaterials();
    },
    onPullingDown() {
      this.options.pullUpLoad = true
      this.onBottom = false
      this.learningMaterialses = [];
      console.log('onPullingDown')
      this.pageIndexLearning = 1
      this.learningMaterials()
    },
    onPullingUpTopic() {
      console.log("onPullingUpTopic");
      this.learningExperience();
    },
    onPullingDownTopic() {
      this.optionsTopic.pullUpLoad = true
      this.onBottom = false
      this.learningExperiences = [];
      console.log('onPullingDownTopic')
      this.learningExperiencesIndex = 1
      this.learningExperience()
    },
    onPullingUpMemorabilia() {
      console.log("onPullingUpMemorabilia");
      this.memorabilia();
    },
    onPullingDownMemorabilia() {
      this.optionsMemorabilia.pullUpLoad = true
      this.onBottom = false
      this.memorabilias = [];
      console.log('onPullingDownMemorabilia')
      this.memorabiliaIndex = 1
      this.memorabilia()
    },
    /*学习资料*/
    learningMaterials() {
      this.abnormal = false;
      this.isLoading = true;
      this.tabIndex = 5;
      let data = {
        loginId: this.userInfo.id || "112029",
        orgId: this.id,
        spaceType: "5",
        pageNo: this.pageIndexLearning,
        pageSize: "10",
      };
      this.fetchService.spaceInfoList(data).then((res) => {
        this.isLoading = false;
        console.log(res);
        if (res.code !== 0) {
          if (res.code == 444) {
            this.abnormal = true;
            return;
          } else {
            return this.tools.tip(res.message);
          }
        }
        if (res.code === 0 && res.data.length < 1) {
          this.onBottom = true
          this.options.pullUpLoad = false
          this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate();
          return;
        }
        this.pageIndexLearning++;
        this.learningMaterialses = this.learningMaterialses.concat(res.data)
        console.log('this.learningMaterialses',this.learningMaterialses);
        setTimeout(() => {
          this.$refs.scroll.forceUpdate &&
          this.$refs.scroll.forceUpdate(true, false);
        }, 100);
      });
    },
    showImg(fileId) {
      let fileUrl = this.tools.getImgUrl(fileId);
      // console.log("-------------fileUrl=", fileUrl);
      return fileUrl;
    },
    goMemorabiliasDetail(item, index) {
      console.log('item.externalUrl=',item.externalUrl);
      if (item.externalUrl.indexOf('source') != -1) {
        let url = item.externalUrl.substring(0, item.externalUrl.lastIndexOf('source') - 1)
        let source = Number(item.externalUrl.substring(item.externalUrl.lastIndexOf('=') + 1));
        this.saveSpaceInfoRead(item.id);
          if (source == 1) {//1 视频
            this.$store.state.isVideo = true
            this.getDetail(item)
            return
          } else if (source == 6) {//6 红云FM
            this.$store.state.isVideo = false
            this.getDetail(item)
            return
          }
          if(url.indexOf('redCloudNewsDetail')!=-1){//红云头条
            let newId = item.externalUrl.substring(item.externalUrl.lastIndexOf('/') + 1 , item.externalUrl.indexOf('?'))
            console.log('newIdnewId=',newId);
            return this.$router.push({name: 'redCloudNewsDetail', params:{id: newId,isComment:false,title:'学习资料',isUpsComponent:false,allowProhibit:false}});
          }
          if(url.indexOf('groupInfoDetail')!=-1){//贵阳党工信息
            let id = item.externalUrl.substring(item.externalUrl.lastIndexOf('id') + 3, item.externalUrl.indexOf('&'))
            return this.$router.push({name: 'groupInfoDetail',query:{id: id}, params:{isComment:false,title:'学习资料',isUpsComponent:false,allowProhibit:false}});
          }
          this.$router.push({path: url});
          return
      }
      // 外部链接直接打开，不用支持编辑及删除 汤达 2020年6月26日14:45:29
      if (item.externalUrl) {
        this.saveSpaceInfoRead(item.id);
        item.readResult = 1;
        return this.loadUrl(item.externalUrl);
      }
      this.$router.push({
        path: `/branchMemorabiliaDetail/${item.id}/${index}`,
      });
    },
    getDetail(item){
      let id = item.externalUrl.substring(item.externalUrl.lastIndexOf('id') + 3, item.externalUrl.indexOf('&'))
      return this.fetchService.contentPageDetail(id).then(res => {
        if (res.code !== 0) {
          return false
        }
        this.$store.state.videoDetail = res.data.newsContent
        console.log('this.$store.state.videoDetail',this.$store.state.videoDetail);
        this.$router.push({
          name: `videoDetail`, params: {id: res.data.newsContent.id,title:'学习资料',isComment:false,isUpsComponent:false,allowProhibit:false}, query: {id: res.data.newsContent.id}
        });
      })

    },
    goTopicDetail(item, index) {
      console.log('item=', item)
      this.$store.state.topicDetail = item
      this.$router.push({
        // path: `/branchMemorabiliaDetail/${item.id}/${index}`,
        path: `/branchTopicDetail`, name: 'branchTopicDetail'
      });
    },
    loadUrl(url) {
      window.android &&
      window.android.openUrlAdapt &&
      window.android.openUrlAdapt(url);
    },
    goAlbums(item, index) {
      this.$router.push({
        name: `albumsDetail`,
        query: {id: item.id, index: index},
      });
    },
    download(data) {
      // this.downloadFlag = true
      // loginService.download(fileId).then((res) => {
      //   if (res.code !== 0) {
      //     return tools.tip(res.message)
      //   }
      // })
      this.downLoadFile(data);
    },
    partInfo() {
      let data = {
        loginId: "112029",
        spaceType: "4",
        pageSize: "200",
      };
      this.fetchService.getOrgInfoByUser(data).then((res) => {
        console.log(res);
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
        this.partInfoData = res.data;
      });
    },
    spaceCover() {
      let data = {
        loginId: "112029",
        orgId: this.id,
        spaceType: "1",
        pageNo: "1",
        pageSize: "200",
      };
      this.fetchService.spaceInfoList(data).then((res) => {
        console.log(res);
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
        this.spaceCovers = res.data;
        if (this.spaceCovers && this.spaceCovers.length > 0) {
          this.spaceCoverFileId = this.spaceCovers[0].fileId;
        }
      });
    },
    downLoadFile(item) {
      console.log("item={}", item);
      let url = this.tools.getImgUrl(item.fileId);
      if (window.android && window.android.downloadFile) {
        window.android.downloadFile(url, item.fileName + "cest.docx");
      }
    },
    getTime(createTime) {
      return moment(createTime).format("YYYY年MM月DD日");
    },
    getTimeNew(createTime) {
      if (new Date(createTime).getFullYear() > new Date().getFullYear()) {
        return moment(createTime).format("YYYY-M-D");
      }
      return moment(createTime).format("M-D");
    },
    readSpaceInfoStatusList() {
      let data = {
        loginId: "305557",
        spaceType: "",
      };
      this.fetchService.readSpaceInfoStatusList(data).then((res) => {
        console.log(res);
        if (res.code === 0) {
          res.data.map((v) => {
            if (v.type === "2") {
              this.zbdsjRead = v.noReadTotal;
            } else if (v.type === "3") {
              this.zbxcRead = v.noReadTotal;
            } else if (v.type === "4") {
              this.xxthjRead = v.noReadTotal;
            } else if (v.type === "5") {
              this.xxzljRead = v.noReadTotal;
            }
          });
        }
      });
    },
    goAdd(name) {
      this.$store.state.selectCollectList = []; //清空选择的收藏列表
      this.$router.push({name: name});
    },
    goAddSpace() {
      this.$router.push({path: `/spaceCoverAdd/${this.partInfoData.id}`,params:{partInfoData : this.partInfoData}});
    },
    callNumber(mobile) {
      if (mobile === "") {
        return;
      }
      if (window.android && window.android.callNumber) {
        window.android.callNumber(mobile);
      }
    },
    saveSpaceInfoRead(id) {
      let data = {
        loginId: "112029",
        spaceId: id,
      };
      this.fetchService.saveSpaceInfoRead(data).then((res) => {
        if (res.code !== 0) {
          return this.tools.tip(res.message);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/common/stylus/moon.scss";
.line-tab li {
  font-size: 16PX;
}
p{
  font-size: 16PX;
}
.albums-text {
  /*width:100%;*/
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  max-height: 4.5em;
  -webkit-box-orient: vertical;
  display: -webkit-box;
}

.live-msg {
  overflow: hidden;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
  max-height: 4.5em;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  font-size: 16PX;
  line-height: 1.5em;
  padding-right: 0.2rem;
}
.study-my {
  padding: 3px;
  background: #fff;
  -webkit-box-shadow: 0px 0.06667rem 0.26667rem 0px rgba(0, 0, 59, 0.1);
  box-shadow: 0px 0.06667rem 0.26667rem 0px rgba(0, 0, 59, 0.1);
  overflow: hidden;
  margin: 0 0 3px 0;
  border-radius: 0px;
  border-radius: 0.3rem;
  margin-bottom: 0.2rem;
  .card-foot-my {
    padding-left: 0.2rem;
    //padding-bottom: 0.3rem;

    .span-my {
      font-weight: normal;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      word-break: break-all;
      font-size: 16PX;
    }

    > p {
      font-size: 12PX;
      margin: 0.2rem 0;
      color:#999999;
    }
  }
}

.people-list {
  .people-item {
    border-radius: 0.3rem;
    margin-bottom: 0.2rem;
    .avatar-img {
      margin-right: 20px;
      flex-shrink: 0;
    }
    .right-my{
      font-size: 16PX;
      width: 10%;
      .color-red{
        margin-top: 0.2rem;
      }
    }
    .cont {
      width: 75%;

      .name {
        /*line-height: 1.5em;*/
        &.title {
          white-space: nowrap;
          height: 1.5em;
          overflow: hidden;
          text-overflow: ellipsis;
          display: block;
          width: 90vw;
        }
      }
    }
  }
}

.banner {
  width: 100%;
  height: pxToRem(240px);
  background: $theme-color;

  img {
    @include fullImg();
  }

  .block-img {
    height: 100%;
    width: 100%;
    position: relative;
    text-align: center;
    background: url("../../../../static/images/dangjian/dangwu/partyAffairs_bg_defalut.png") no-repeat center;
    background-size: 100% auto;

    img {
      width: auto;
      height: 100%;
    }

    .inner-text {
      position: absolute;
      left: 0;
      top: 0;
      @include fullImg();

      .group-name {
        color: #fff;
        position: absolute;
        bottom: 10px;
        left: 10px;
        display: inline-block;
        padding: 10px 30px;
        border-radius: 20px;
        background-color: rgba($theme-color, 0.7);
        font-size: $titleFontSize;
      }

      .banner-avatar-info {
        display: flex;
        padding-top: pxToRem(56px);
        padding-left: pxToRem(56px);

        .avatar-wrap {
          width: pxToRem(118px);
          height: pxToRem(118px);
          border: pxToRem(6px) solid rgba(255, 180, 180, 0.8);
          border-radius: 100%;

          .avatar {
            border-radius: 100%;
            @include fullImg();

            img {
              border-radius: 100%;
              @include fullImg();
            }
          }
        }

        .info {
          margin-left: pxToRem(27px);

          h1 {
            font-size: pxToRem(36px);
            font-weight: bold;
            color: rgba(255, 255, 255, 1);
            line-height: pxToRem(70px);
            opacity: 0.9;
          }

          .text {
            font-size: pxToRem(19px);
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
            line-height: pxToRem(32px);
          }
        }
      }
    }
  }
}

.list-news-img {
  .item {
    border: none;

    .cont {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;

      .title {
        min-height: 0;
        font-size: 16PX;
      }
    }

    /*.img {
      background: none;
      height: 180px;
      border-radius: 30px;

      img {
        //          @include fullImg();
      }
    }*/
  }
}

.cube-swipe-item {
  .live-msg-wrap {
    border-radius: 0.3rem;
    margin-bottom: 0.2rem;
    .live-msg {
      white-space: normal;
      word-break: break-all;
      font-size: 16PX;
      font-weight: bold;
      padding-right: 0.3rem;
    }
    h1 {
      font-size: 16PX;
    }
  }
}

.live-msg-wrap .user-avatar {
  padding: 0.17rem;
  .user-avatar .avatar {
    width: 1rem;
    height: 1rem;
  }
  .info {
    flex: 1;

    h1 {
      font-size: 16PX;
    }
    .header-my{
      color: #999999;
    }
  }

  .no-wrap {
    align-self: flex-start;
    padding-top: 10px;
  }
}

.people-list .people-item .user-avatar .color-tip {
  font-size: 16PX;
}
.people-list .people-item-my{
  display: flex;
  justify-content: end;
}
.people-list .people-item .name {
  line-height: 1.5em;
  font-size: 16PX;
  color: #333333;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-direction: column;
  flex-direction: column;
  overflow: hidden;
}
.page-my{
  height: calc(100vh - 5.66667rem);
}
.head-my {
  font-size: 16PX;
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin: 0.2rem 0;
  .right {
    margin-right: 4%;
    color: #D81E06;

    .icon-delete {
      display: inline-block;
      background: url('../../../../static/images/dangjian/home/icon-delete-red.png') no-repeat center;
      width: 0.4rem;
      height: 0.4rem;
      background-size: 100% 100%;
      margin-right: 0.13333rem;
    }
  }
}
.d-scroll {
  height: calc(100vh - 5.8rem - .66667rem);
}
.border-my{
  border-radius: 0.3rem;
  margin-bottom: 0.2rem;
}
.imgs {
  display:flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  .img {
    /* width:33%;
     flex-shrink: 0;
     background:$gray-color;
     font-size:0;*/
    margin-right:1.1%;
    display: inline-block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    img {@include fullImg();}
  }

}
</style>
